package com.jiaozi.system.controller;


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.jiaozi.core.annotation.Log;
import com.jiaozi.core.table.JzTable;
import com.jiaozi.base.utils.bean.R;
import com.jiaozi.system.pojo.param.sys.configs.UpdateConfigValueParam;
import com.jiaozi.system.pojo.vo.sys.configs.ConfigListVO;
import com.jiaozi.system.service.SysConfigsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


/**
 * 系统-参数配置(SysConfigs)表控制层
 *
 * @author 张崇阳
 * @since 2024-09-23 10:05:03
 */
@RestController
@RequestMapping("/sysConfigs")
public class SysConfigsController {
    /**
     * 服务对象
     */
    @Autowired
    private SysConfigsService sysConfigsService;


    @Operation(summary = "参数初始化",description = "参数初始化")
    @GetMapping("/info")
    @ApiOperationSupport(order = 1)
    @Log("参数初始化")
    public  R<JzTable> info(){
        JzTable jzTable=new JzTable(ConfigListVO.class);
        jzTable.setRefreshBotton(true);
        jzTable.setColumnsBotton(true);
        jzTable.setPage(false);
        jzTable.setDataUrl("/sysConfigs/configList");
        return R.ok(jzTable);
    }

    @Operation(summary = "查询系统参数列表",description = "查询系统参数列表")
    @GetMapping("/configList")
    @ApiOperationSupport(order = 1)
    public R<List<ConfigListVO>> configList(){
        return sysConfigsService.configList();
    }

    @Operation(summary = "查询系统参数",description = "查询系统参数")
    @GetMapping("/{configId}")
    @ApiOperationSupport(order = 3)
    public R<ConfigListVO> departmentInfo(@Parameter(name ="configId" ,description = "参数id", required = true)
                                          @PathVariable(value = "configId") String configId){
        return sysConfigsService.configInfo(configId);

    }

    @Operation(summary = "修改系统参数值",description = "修改系统参数值")
    @PutMapping("/updateConfigValue/{configId}")
    @ApiOperationSupport(order = 2)
    @Log("修改系统参数值")
    public R updateConfigValue(@Parameter(name ="configId" ,description = "参数编号", required = true)
                                   @PathVariable(value = "configId") String configId,@RequestBody UpdateConfigValueParam updateConfigValueParam){
        return sysConfigsService.updateConfigValue(configId,updateConfigValueParam);
    }


}

